﻿Imports System
Imports System.Web

Public MustInherit Class BaseModuleRewriter
    Implements IHttpModule

    Protected Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
        AddHandler context.AuthorizeRequest, AddressOf BaseModuleRewriter_AuthorizeRequest
    End Sub


    Private Sub BaseModuleRewriter_AuthorizeRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim app As HttpApplication = CType(sender, HttpApplication)
        'Rewrite(app.Context.Request.RawUrl, app)
        '分离?字符
        Dim absUrl As String = app.Request.Url.AbsoluteUri.Split(CChar("?"))(0)
        '分离#字符
        If absUrl.Contains("#") Then
            absUrl = absUrl.Substring(0, absUrl.IndexOf("#"))
        End If

        Rewrite(absUrl, app)
    End Sub

    Protected MustOverride Sub Rewrite(ByVal requestedPath As String, ByVal app As HttpApplication)

    Protected Sub Dispose() Implements System.Web.IHttpModule.Dispose

    End Sub
End Class



